* src/json.c (make_symset_table): Fix over-large allocation size.
authorMattias Engdegård <mattiase@acm.org>
Thu, 4 Apr 2024 10:21:26 +0000 (12:21 +0200)
committerMattias Engdegård <mattiase@acm.org>
Thu, 4 Apr 2024 10:24:22 +0000 (12:24 +0200)
We multiplied when we should have added.  Oops.

src/json.c

index 33c3289b394436ca57911b604b6c9e40ddea946d..702350b1b0954c0676160ca7008f00e2c93e2be7 100644 (file)
@@ -143,7 +143,7 @@ make_symset_table (int bits, struct symset_tbl *up)
   int maxbits = min (SIZE_WIDTH - 2 - (word_size < 8 ? 2 : 3), 32);
   if (bits > maxbits)
     memory_full (PTRDIFF_MAX); /* Will never happen in practice.  */
-  struct symset_tbl *st = xnmalloc (sizeof *st->entries << bits, sizeof *st);
+  struct symset_tbl *st = xmalloc (sizeof *st + (sizeof *st->entries << bits));
   st->up = up;
   ptrdiff_t size = symset_size (bits);
   for (ptrdiff_t i = 0; i < size; i++)